Release 10.1A: OpenEdge Development:
Progress 4GL Handbook


Navigation methods

There is a dynamic navigation method for each of the corresponding GET statements: GET-FIRST, GET-NEXT, GET-PREV, and GET-LAST. There is also a GET-CURRENT method that corresponds to the GET CURRENT statement, which again retrieves the current record from the database, normally to check to see whether it has been changed since you last read it.

These methods can take optional arguments that you can use to specify the lock mode (NO-LOCK, SHARE-LOCK, or EXCLUSIVE-LOCK) and wait mode (if it is NO-WAIT). The default lock mode is SHARE-LOCK. You will generally want to change this default to specify either NO-LOCK or EXCLUSIVE-LOCK, depending on whether you need to prepare for it to be changed and protect the record against changes by other users.

Here’s a completion of the simple procedure used throughout this section, showing the QUERY-PREPARE, QUERY-OPEN, and GET-NEXT methods and the use of the QUERY-OFF-END attribute:

DEFINE VARIABLE hQuery    AS HANDLE     NO-UNDO. 
DEFINE VARIABLE iBufNum   AS INTEGER    NO-UNDO. 
DEFINE VARIABLE cBufNames AS CHARACTER  NO-UNDO. 
DEFINE VARIABLE lSuccess  AS LOGICAL    NO-UNDO. 
CREATE QUERY hQuery. 
hQuery:SET-BUFFERS(BUFFER Order:HANDLE, BUFFER Customer:HANDLE). 
hQuery:ADD-BUFFER(BUFFER SalesRep:HANDLE). 
lSuccess =  
     hQuery:QUERY-PREPARE("FOR EACH Order WHERE OrderStatus = 'Ordered', " 
                       + "FIRST Customer OF Order, "  
                       + "FIRST SalesRep OF Order " 
                       + "BY SalesRep"). 
IF NOT lSuccess OR ERROR-STATUS:NUM-MESSAGES NE 0 THEN 
DO: 
    /* Deal with possible errors in the Query Prepare. */ 
END. 
hQuery:QUERY-OPEN(). 
REPEAT WHILE NOT hQuery:QUERY-OFF-END: 
    hQuery:GET-NEXT(). 
    DISPLAY Order.OrderNum Customer.NAME FORMAT "x(20)" 
        SalesRep.RepName WITH FRAME OrderFrame 10 DOWN. 
END. 
hQuery:QUERY-CLOSE(). 
DELETE OBJECT hQuery. 

Figure 19–8 shows the result.

Figure 19–8: Result of query methods and attributes example


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095